package cn.buk.tms.dto;

import cn.buk.tms.entity.base.Airport;
import org.springframework.beans.BeanUtils;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 机场信息DTO
 * @author yfdai
 */
public class AirportDto {

	/**
	 * 机场代码
	 */
	@NotNull
	@Size(min = 3, max = 3)
	private String threeCode;

	/**
	 * 机场中文名称
	 */
	private String airportName;

	/**
	 * 机场英文名称
	 */
	private String airportEnglishName;

	private String airportType;

	/**
	 * 国家代码
	 */
	@NotNull
	@Size(min = 2, max = 3)
	private String countryCode;

	/**
	 * 城市代码
	 */
	@NotNull
	@Size(min = 3, max = 3)
	private String cityCode;

	/**
	 * 城市中文名称
	 */
	private String cityName;

	public static AirportDto createBy(Airport obj) {
		AirportDto dto = new AirportDto();

		BeanUtils.copyProperties(obj, dto);
		dto.setAirportName(obj.getNameCN());
		dto.setAirportEnglishName(obj.getNameEN());

		return dto;
	}

	public static Airport convertTo(AirportDto dto) {
		Airport obj = new Airport();

		BeanUtils.copyProperties(dto, obj);
		obj.setNameCN(dto.getAirportName());
		obj.setNameEN(dto.getAirportEnglishName());

		return obj;
	}

	public String getThreeCode() {
		return threeCode;
	}

	public void setThreeCode(String threeCode) {
		this.threeCode = threeCode.toUpperCase().trim();
	}


	public String getAirportType() {
		return airportType;
	}

	public void setAirportType(String airportType) {
		this.airportType = airportType;
	}

	public String getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode.trim().toUpperCase();
	}


	public String getCityCode() {
		return cityCode;
	}

	public void setCityCode(String cityCode) {
		this.cityCode = cityCode.trim().toUpperCase();
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}


	public String getAirportName() {
		return airportName;
	}

	public void setAirportName(String airportName) {
		this.airportName = airportName;
	}

	public String getAirportEnglishName() {
		return airportEnglishName;
	}

	public void setAirportEnglishName(String airportEnglishName) {
		this.airportEnglishName = airportEnglishName;
	}
}
